<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="../inc/js.jsp"/>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>操作日志管理</title>
    <jsp:include page="../inc/css.jsp"/>
</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">
    <jsp:include page="../inc/menu.jsp"/>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Main content -->
        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-12">
                    <div class="card" style="margin-top: 10px">
                        <!-- /.card-header -->
                        <div class="card-header">
                            <div class="form-inline" style="margin-top: 10px;">
                                <div class="form-group searchDiv">
                                    <input id="startTime" readonly placeholder="起始时间" class="form-control" style="margin-right: 10px;width: 150px;"/>
                                </div>
                                <span style="margin-right: 10px;">~</span>
                                <div class="form-group searchDiv">
                                    <input id="endTime" readonly placeholder="截止时间" class="form-control" style="margin-right: 10px;width: 150px;"/>
                                </div>

                                <div class="form-group">
                                    <input id="searchKeyWord" placeholder="IP地址或内容" class="form-control" style="margin-right: 10px;"/>
                                </div>

                                <button type="button" title="查询" class="btn btn-info" onclick="_logInfoList.fn.reloadData()">
                                    查询
                                </button>
                            </div>
                        </div>
                        <div class="card-body">
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered table-hover" id="dataTables" style="width: 99%">
                                    <colgroup>
                                        <col class="gradeA even"/>
                                        <col class="gradeA odd"/>
                                        <col class="gradeA even"/>
                                    </colgroup>
                                    <thead>
                                    <tr>
                                        <th>记录IP</th>
                                        <th>日志内容</th>
                                        <th style="max-width: 160px">记录时间</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <!-- /.card-body -->
                    </div>
                    <!-- /.card -->
                </div>
                <!-- /.col -->
            </div>
            <!-- /.row -->
        </section>
        <!-- /.content -->
    </div>
</div>
<!-- ./wrapper -->

<!-- page script -->
<script type="text/javascript">
    var _logInfoList = {
        v: {
            list: [],
            dTable: null
        },
        fn: {
            init: function () {
                laydate.render({
                    elem: '#startTime'
                    , type: 'datetime'
                    /*, min: _deviceInfoList.fn.getLastWeekDate()*/
                });

                laydate.render({
                    elem: '#endTime'
                    , type: 'datetime'
                    /*, max: _deviceInfoList.fn.getNowWeekDate()*/
                });

                _logInfoList.fn.dataTableInit();
            },
            reloadData: function () {
                _logInfoList.v.list = [];
                _logInfoList.v.dTable.DataTable().ajax.reload(null, false);
            },
            dataTableInit: function () {
                _logInfoList.v.dTable = $tutu.dataTable($('#dataTables'), {
                    "processing": true,
                    "serverSide": true,
                    "autoWidth": true,//自动计算宽度
                    "lengthChange": false,//是否允许用户改变表格每页显示的记录数
                    "searching": false,
                    "ordering": false,
                    "ajax": {
                        "url": "backend/logInfo/list",
                        "type": "POST"
                    },
                    "language": $tutu.v.dataTableL,
                    "columns": [
                        {"data": "ip"},
                        {"data": "content"},
                        {
                            "data": "createTime",
                            render: function (data) {
                                return crtTimeFtt(data);
                            }
                        }
                    ],
                    /*添加小插件*/
                    "columnDefs": [],
                    /*展示数据格式化*/
                    "createdRow": function (row, data, index) {
                        _logInfoList.v.list.push(data);
                    },
                    /*回调函数*/
                    rowCallback: function (row, data) {

                    },
                    /*带操作日志*/
                    "fnServerParams": function (aoData) {
                        _logInfoList.v.list = [];
                        aoData.keyWord = $('#searchKeyWord').val();
                        aoData.startTime = $('#startTime').val();
                        aoData.endTime = $('#endTime').val();
                    },
                    "fnDrawCallback": function (data) {
                        $tutu.uiForm(data);
                    }
                });
            }
        }
    };

    $(document).ready(function () {
        _logInfoList.fn.init();

        window.onload = function () {
            checkSelectMenu("logInfoLi");

            loadMenuColor('logInfoLi');
        }
    });
</script>
</body>
</html>
